package sng.net.http
{
	import flash.utils.ByteArray;

	/**
	 * 网络连接客户端
	 * 接收和发送消息  
	 * @author leonliu
	 * 
	 */	
	public class NetClient
	{
		
		/**
		 *  
		 */		
		static private var _instance:NetClient = null;
		
		
		/**
		 * http代理
		 */		
		private var _httpProxy:HttpProxy;
		
		
		
		public function NetClient()
		{
			
			_httpProxy = new HttpProxy(this);
		}
		
		
		/**
		 * 获取实例 
		 * @return 
		 * 
		 */		
		static public function get instance():NetClient
		{
			if(null == _instance)
			{
				_instance = new NetClient();
			}
			
			return _instance;
		}
		
		
		
		/**
		 * 发送数据给服务器 
		 * @param msg  发送的的数据
		 * @param onRecv 接收数据的函数，这里回调数据为ByteArray
		 * @return 
		 * 
		 */
		public function sendMsg(buf:ByteArray, onRecv:Function):uint
		{
			return _httpProxy.sendMsg(buf, onRecv);
		}
	}
}